<template>
<!-- 详情页 -->
  <div class="product-detail">
    <detail-logo></detail-logo>
    <detail-nav :name="detail.name" :productid="detail.id"></detail-nav>
    <div class="container flex-space-bet">
      <div class="product-img">
        <img :src="detail.mainImage" />
      </div>
      <div class="desc-container">
        <h3 class="title">{{detail.name}}</h3>
        <div class="desc">
          {{detail.subtitle}}
        </div>
        <h3 class="price-title">小米自营</h3>
        <p class="price">{{detail.price}}元<del>{{detail.price}}元</del></p>

        <div class="address-content">
          <p>北京 北京市 朝阳区 安定门街道<span class="change-addr">修改</span></p>
          <p class="isfalse">有现货</p>
        </div>

        <div class="product-edition">
          <h4>选择版本</h4>
          <div class="item-container">
            <div class="edition-item product-item">
              <span class="parameter">6GB+64GB 全网通</span>
              <span class="price">{{detail.price}}元</span>
            </div>
            <div class="edition-item product-item">
              <span class="parameter">4GB+64GB 移动4G</span>
              <span class="price">{{detail.price}}元</span>
            </div>
            <div class="edition-item product-item">
              <span class="parameter">4GB+64GB 移动4G</span>
              <span class="price">{{detail.price}}元</span>
            </div>
          </div>
        </div>

        <div class="product-color">
          <h4>选择颜色</h4>
          <div class="item-container">
            <div class="color-item product-item">
              <span class="product-bg"></span>
              <span class="bg-desc">深空灰</span>
            </div>
          </div>
        </div>

        <div class="product-price-content">
          <div class="price-title flex-space-bet">
            <div class="left">小米8 6GB+64GB 全网通 深灰色</div>
            <div class="right">{{detail.price}}元<del class="undline">{{detail.price}}元</del></div>
          </div>
          <div class="price">总计：{{detail.price}}元</div>
        </div>

        <button class="add-car-btn" @click="addCart">加入购物车</button
        ><button class="love-btn">喜欢</button>
      </div>
    </div>
    <div class="price-description">
      <div class="container">
        <h3>价格说明</h3>
        <div class="content">
          划线价:十六点九分零四九分零四送到房间里伺机待发少了几分老师大家斯蒂芬弗雷精神分裂收到两份简历是觉得十六点九分零四九分零四送到房间里伺机待发少了几分老师大家斯蒂芬弗雷精神分裂收到两份简历是觉得十六点九分零四九分零四送到
          房间里伺机待发少了几分老师大家斯蒂芬弗雷精神分裂收到两份简历是觉得
        </div>
      </div>
    </div>
    <detail-service></detail-service>
  </div>
</template>

<script>
import DetailLogo from "../../components/Logo";
import DetailNav from "./components/DetailNav";
import DetailService from "../index/components/Service";
export default {
  name: "Detail",
  data(){
    return{
      detail: {},
    }
  },
  mounted(){
    this.getProductInfo();
  },
  methods: {
    addCart(){
      let id = this.$route.params.id;
      this.axios.post('/carts',{
        productId: id,
        selected: true
      }).then(res => {
        // console.log(res)
        this.$router.push('/index/joincart')
      })
    },
    getProductInfo(){
      let id = this.$route.params.id;
      this.axios.get('/products/'+id).then(res => {
        this.detail = res;
      })
    }
  },
  components: {
    DetailLogo,
    DetailNav,
    DetailService,
  },
};
</script>

<style lang="scss">
.product-detail {
  padding-bottom: 50px;
  .product-img {
    width: 50%;
    padding-top: 90px;
    img {
      width: 384px;
    }
  }
  .desc-container {
    div,
    p,
    h3,
    span,
    h4 {
      text-align: left;
    }
    .title {
      font-size: 28px;
      font-family: FZLanTingHeiS-R-GB;
      font-weight: bold;
      color: #333333;
      line-height: 60px;
    }
    .desc {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #999999;
      margin: 16px 0 26px;
    }
    .price-title {
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #ff6700;
      line-height: 22px;
    }
    .price {
      font-size: 20px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #ff6700;
      padding-bottom: 25px;
      border-bottom: 2px solid #eee;
      del {
        font-size: 14px;
        color: #999999;
        margin-left: 5px;
      }
    }
    .address-content {
      padding: 31px 34px;
      background: #fafafa;
      border: 1px solid #e5e5e5;
      margin-top: 30px;
      font-size: 14px;
      font-family: FZLanTingHeiS-R-GB;
      font-weight: bold;
      color: #666666;
      line-height: 30px;
      .change-addr{
        color: #ff6700;
        margin-left: 10px;
        cursor: pointer;
      }
      .isfalse{
          color:#ff6700;
      }
    }
    h4 {
      font-size: 18px;
      font-family: FZLanTingHeiS-R-GB;
      font-weight: bold;
      color: #333333;
      line-height: 60px;
    }
    .item-container {
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      font-size: 16px;
      font-family: FZLanTingHeiS-R-GB;
      font-weight: bold;
      .product-item {
        width: 287px;
        height: 50px;
        line-height: 50px;
        text-align: center;
        border: 1px solid #ff6600;
        margin: 10px 0;
        cursor: pointer;
        .price {
          color: #999;
          margin-left: 10px;
          font-size: 14px;
        }
        .product-bg {
          display: inline-block;
          margin-right: 5px;
          position: relative;
          top: 1px;
          width: 14px;
          height: 14px;
          background: #eee;
        }
      }
    }
    .product-price-content {
      margin-top: 50px;
      background: #fafafa;
      padding: 24px 30px 29px;
      margin-bottom: 49px;
      .price-title {
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #333333;
        .undline{
            font-size: 12px;
        }
      }
      .price {
        font-size: 24px;
        font-family: PingFang SC;
        font-weight: bold;
        color: #ff6600;
        margin-top: 18px;
        border: none;
      }
    }
    .add-car-btn {
      padding: 10px 40px;
      margin-right: 30px;
    }
    .love-btn {
      padding: 10px 20px;
      background: #888;
    }
  }
  .price-description {
    background: #eee;
    overflow: hidden;
    margin-top: 50px;
    padding-bottom: 30px;
    h3 {
      text-align: left;
      font-size: 24px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #333333;
      line-height: 60px;
    }
    .content {
      padding: 20px 30px;
      background: #fff;
      text-align: left;
      line-height: 30px;
    }
  }
}
</style>